package com.jcl.recruit.corp.logic;

import com.jcl.core.utils.BaseUtils;
import com.jcl.core.utils.CollectionUtils;
import com.jcl.core.utils.DateUtils;
import com.jcl.recruit.core.constants.Constants;
import com.jcl.recruit.corp.dao.SubcompanyDao;
import com.jcl.recruit.corp.model.Subcompany;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.*;

/**
 * @ClassName SubcompanyLogic

 * @Author yyliu
 * @Date 2018/9/12 17:20
 * @Version 1.0
 **/
@Component
public class SubcompanyLogic {

    @Autowired
    private SubcompanyDao subcompanyDao;

    public Map<String, String> getCorpNameMap(List<String> corpCodes){
        Map<String, String> map = new HashMap<>();
        if(CollectionUtils.isNotEmpty(corpCodes)){
            for(String code: corpCodes){
                Subcompany subcompany = subcompanyDao.findOneByCode(code);
                map.put(subcompany.getCode(), subcompany.getFullname());
            }
        }
        return map;
    }
    
    public List<Subcompany> selectAllComanyInfosBySuperId(Integer superId) {
        return subcompanyDao.selectAllComanyInfosBySuperId(superId);
    }

    public Subcompany findOneByCode(String code) {
        return subcompanyDao.findOneByCode(code);
    }

    public Subcompany findOneById(Integer id) {
        return subcompanyDao.findOneById(id);
    }

    public int add(Subcompany company) {
        return subcompanyDao.add(company);
    }

    public int update(Subcompany company) {
        return subcompanyDao.update(company);
    }

    public int updateAddUser(String corpCode, Integer id, Integer userId) {
        return subcompanyDao.updateAddUser(corpCode, id, userId);
    }
}
